package com.itwn.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itwn.entity.UrlPermission;
import com.itwn.mapper.UrlPermissionMapper;
import com.itwn.vo.PermissionsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UrlPermissionService {

    @Autowired
    UrlPermissionMapper urlPermissionMapper;

    public PageInfo<UrlPermission> findWithPage(Integer pageNum, Integer pageSize, String name) {
        PageHelper.startPage(pageNum,pageSize);
        List<UrlPermission> list= urlPermissionMapper.selectByName(name);
        return new PageInfo<>(list);
    }

    public int updatePer(UrlPermission urlPermission) {
        return urlPermissionMapper.updateByPrimaryKey(urlPermission);
    }

    public int addPer(UrlPermission urlPermission) {
        return urlPermissionMapper.insert(urlPermission);
    }


    public List<UrlPermission> findList() {
        List<UrlPermission> list= urlPermissionMapper.selectByName(null);
        return list;
    }

    public int removePermission(Long id) {
        return urlPermissionMapper.deleteByPrimaryKey(id);
    }

}
